﻿#ifndef SQLITEUTIL_H
#define SQLITEUTIL_H
#include <QDebug>
#include <QtSql/qsql.h>
#include <QtSql/QSqlError>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QList>
#include <QObject>
#include <QTime>
#include <QFile>
#include <QDataStream>
#include <QFileInfo>
#include <QVector>
#include <QtMath>


struct PDXP2 {
	quint8 VER;
	quint16 MID;
	quint32 SID;
	quint32 DID;
	quint32 BID;
	quint32 NO;
	quint8 FLAG;
	quint32 Res;
	quint16 JD;
	quint32 JS;
	quint16 LEN;
	QDate date(void);
	QTime time(void);
};

QDataStream& operator >>(QDataStream& is, PDXP2& pdxp);

class SqliteUtil
{
public:
	SqliteUtil();
	~SqliteUtil();

	void init();

	bool createConnection(QString dbname);

	void disConnection();

	bool createTabel(QString fileName);

	void insertData(QVector<qint64> records);
	void updateData();
	void selectData();


	int getMaxValue();
	int getMinValue();
	int getAllCount();

	double getVariance();

	double getAvgValue();

	bool isExistTab(QString tbname);

	int selectRangeCount(int min, int max);
	QMap<int, int> selectRepetRecords();

	void dropTab(QString tbname);

	void strToSql(QString& str);

	QString jsLineString(quint32 js);


	void getProssBarValue(int& row, int& rowMax);


	bool m_bDiscontinue;
	QString m_sTbname;
private:



	QFile file;
	int m_nRow;
	int m_nRowMax;


	QString m_strInitialPath;
	

};

#endif // SQLITEUTIL_H
